package com.lankystar.logistucs.spring.dao.impl;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.lankystar.logistucs.spring.dao.IOrderStatusDao;
import com.lankystar.logistucs.spring.entity.LastStatus;
import com.lankystar.logistucs.spring.entity.OneStatus;
import com.lankystar.logistucs.spring.entity.TwoStatus;

@Repository
public class OrderStatusDaoImpl extends BaseDaoImpl implements IOrderStatusDao{

	@Autowired
	private SessionFactory sf;
	
	public Session getSession(){
		System.out.println("session oneOrderDaoImpl");
		return sf.getCurrentSession();
	}
	
	@Override
	public OneStatus selectOneStatusBykey(int oneStatusKey) {
		String sql = "from OneStatus where oneStatusKey = ?";
		OneStatus oneStatus = (OneStatus) getSession().createQuery(sql).setInteger(0, oneStatusKey).uniqueResult();
		return oneStatus;
	}

	@Override
	public TwoStatus selectTwoStatusBykey(int twoStatusKey) {
		String sql = "from TwoStatus where twoStatusKey = ?";
		TwoStatus twoStatus = (TwoStatus) getSession().createQuery(sql).setInteger(0, twoStatusKey).uniqueResult();
		return twoStatus;
	}

	@Override
	public LastStatus selectLastStatusBykey(int lastStatusKey) {
		String sql = "from LastStatus where lastStatusKey = ?";
		LastStatus twoStatus = (LastStatus) getSession().createQuery(sql).setInteger(0, lastStatusKey).uniqueResult();
		return twoStatus;
	}

}
